package br.com.projeto.model.util;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Utilities {

	public static String hashPassword(String password) {

		String hashword = null;

		try {

			MessageDigest md5 = MessageDigest.getInstance("MD5");

			md5.update(password.getBytes());

			BigInteger hash = new BigInteger(1, md5.digest());

			hashword = hash.toString(16);

		} catch (NoSuchAlgorithmException nsae) {

			throw new IllegalStateException(nsae);

		}

		return hashword;

	}

	public static String formataData(Date date){
		SimpleDateFormat formata = new SimpleDateFormat("dd/MM/yyyy");
		return formata.format(date);
	}
	
}
